Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fraction.js

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fraction.js

A rational number library

  • 4.3.7
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is fraction.js?

The fraction.js npm package is a library for handling fractional values in JavaScript. It allows for the creation, manipulation, and conversion of fractions, providing a way to perform arithmetic operations and comparisons with fractions.

What are fraction.js's main functionalities?

Creating fractions

This feature allows for the creation of fraction instances from strings, numbers, or other fractions.

const Fraction = require('fraction.js');
let fraction = new Fraction('9/5');

Arithmetic operations

This feature enables the performance of arithmetic operations such as addition, subtraction, multiplication, and division between fractions.

let result = new Fraction(1, 2).add(new Fraction(1, 4));

Comparison operations

This feature allows for the comparison of fractions to check for equality, or to determine which is greater or less than the other.

let isEqual = new Fraction(1, 2).equals(new Fraction(2, 4));

Conversion to other formats

This feature provides methods to convert fractions to other formats, such as decimal values or strings.

let decimal = new Fraction(3, 4).valueOf();

Other packages similar to fraction.js

Keywords

FAQs

Package last updated on 12 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc